<?php
header("content-type:text/html;charset=utf-8");
include "../public/config/config.php";
include "../public/include/funcs.php";
include "../public/include/money.class.php";
$obj=new money($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
$link=conn($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
if($_POST['tic_yi']){
	$arr_post=$_POST;
	unset($arr_post['id']);
	save($link, "tic", $arr_post);
}
$id=$_REQUEST['id'];
$arr=select($link, "user","id=$id");
$arr[0]['self_xf']=$obj->self_xf($id);
$arr[0]['all_xf']=$obj->all_xf($id);
$name = $arr[0]['tname'] ? $arr[0]['tname'] : $arr[0]['nickname'];
$title_name=$name." -- 业绩详情";

$tic=select($link, 'tic');
$tic_xf=$tic[0]['tic_xf'];
$tic_yi=$tic[0]['tic_yi'];
$tic_er=$tic[0]['tic_er'];
$tic_san=$tic[0]['tic_san'];

$arr_id=$obj->arr_id($id);
$arr_fx_money=$obj->arr_fx_money($arr_id);

echo "<pre>";
//print_r($tic);
//print_r($arr_post);
//print_r($arr_id);
//print_r($arr_fx_money);
echo "</pre>";
?>
<html>
	<head>
		<meta charset="UTF-8">
		<title><?php echo $title_name;?></title>
		<link rel="stylesheet" type="text/css" href="../public/css/main.css"/>
	</head>
	<body>
<div class="tab">
	<h3><?php echo $title_name;?></h3>
	<table border="1" cellspacing="0" cellpadding="0">
		<tr>
			<th>ID号</th>
			<th>真实姓名</th>
			<th>用户名</th>
			<th>总消费(元)</th>
			<th>总业绩（元）</th>
			<th>一级业绩</th>
			<th>二级业绩</th>
			<th>三级业绩</th>
			<th>三级以上的业绩</th>
			<th>操作</th>
		</tr>
		
		<tr>
			<td><?php echo $arr[0]['id'];?></td>
			<td><?php echo $arr[0]['tname'];?></td>
			<td><?php echo $arr[0]['uname'];?></td>
			<td><?php echo $arr[0]['self_xf'];?> &nbsp;&nbsp;&nbsp;<a target="_blank" href="showOne.php?id=<?php echo $id;?>">查看详情</a></td>
			<td><?php echo $arr[0]['all_xf'];?></td>
			<td><?php echo $arr_fx_money[1] ? $arr_fx_money[1] : 0;?></td>
			<td><?php echo $arr_fx_money[2] ? $arr_fx_money[2] : 0;?></td>
			<td><?php echo $arr_fx_money[3] ? $arr_fx_money[3] : 0;?></td>
			<td><?php echo $arr[0]['all_xf']-$arr_fx_money[1]-$arr_fx_money[2]-$arr_fx_money[3];?></td>
			<td>
				<a target="_blank" href="see_top.php?id=<?php echo $arr[0]['id'];?>">查看上级</a>
				<a target="_blank" href="index.php?pid=<?php echo $arr[0]['id'];?>">查看下级</a>
				<a target="_blank" href="see_tree.php?id=<?php echo $arr[0]['id'];?>">查看子集结构</a>
			</td>
		</tr>

		<tr class="tr_hz">
			<td>业绩提成</td>
			<td>-</td>
			<td>-</td>
			<td><?php echo $arr[0]['self_xf']*$tic_xf/100;?></td>
			<td>-</td>
			<td><?php echo $arr_fx_money[1]*$tic_yi/100;?></td>
			<td><?php echo $arr_fx_money[2]*$tic_er/100;?></td>
			<td><?php echo $arr_fx_money[3]*$tic_san/100;?></td>
			<td>三级以上无提成</td>
			<td>合计：<?php echo $arr[0]['self_xf']*$tic_xf/100+$arr_fx_money[1]*$tic_yi/100+$arr_fx_money[2]*$tic_er/100+$arr_fx_money[3]*$tic_san/100;?></td>
		</tr>		
	</table>
	<h3>注：
		自己消费的返金是<?php echo $tic_xf;?>%；
		一级业绩的提成是<?php echo $tic_yi;?>%；
		二级业绩的提成是<?php echo $tic_er;?>%；
		三级业绩的提成是<?php echo $tic_san;?>%；
	</h3>
	<div class="frm w500">
		<form action="yeji.php" method="post">
			<input type="hidden" name="id" value="<?php echo $id?>" />
			<table class="bfb" border="1" cellspacing="0" cellpadding="0">
				<tr>
					<th colspan="2">修改提成比例</th>
				</tr>
				<tr>
					<td>自己消费的返金：</td>
					<td><input type="text" name="tic_xf" value="<?php echo $tic_xf;?>" />%</td>
				</tr>
				<tr>
					<td>一级业绩的提成：</td>
					<td><input type="text" name="tic_yi" value="<?php echo $tic_yi;?>" />%</td>
				</tr>
				<tr>
					<td>二级业绩的提成：</td>
					<td><input type="text" name="tic_er" value="<?php echo $tic_er;?>" />%</td>
				</tr>
				<tr>
					<td>三级业绩的提成：</td>
					<td><input type="text" name="tic_san" value="<?php echo $tic_san;?>" />%</td>
				</tr>
				
				<tr>
					<td colspan="2"><input class="sub" type="submit" value="提交"/></td>
				</tr>
			</table>
			
		</form>
	</div>
</div>
	</body>
</html>